﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._05_建造者模式
{

    /// <summary>
    /// 订单信息
    /// </summary>
    public class OrderInfo
    {
        public string OrderId { get; set; }
        public DateTime CreateTime { get; set; }
        public string Status { get; set; }
        public Customer Customer { get; set; }
        public List<OrderItem> Items { get; set; } = new List<OrderItem>();
        public ShippingInfo Shipping { get; set; }
        public PaymentInfo Payment { get; set; }
        public DiscountInfo Discount { get; set; }
        public InvoiceInfo Invoice { get; set; }

        /// <summary>
        /// 显示订单信息
        /// </summary>
        public void DisplayOrderInfo()
        {
            Console.WriteLine($"订单ID: {OrderId}");
            Console.WriteLine($"创建时间: {CreateTime}");
            Console.WriteLine($"状态: {Status}");
            Console.WriteLine($"客户: {Customer.Name} ({Customer.Email})");

            Console.WriteLine("订单明细：\n");
            foreach (var item in Items)
            {
                Console.WriteLine($"订单商品信息： {item.ProductName} x{item.Quantity} @ {item.UnitPrice:C} = {item.UnitPrice * item.Quantity:C}");
            }

            Console.WriteLine($"\n配送方式: {Shipping.Method} 到 {Shipping.Address}");
            Console.WriteLine($"\n支付方式: {Payment.Method} 金额: {Payment.Amount:C}");
            if (Discount != null)
            {
                Console.WriteLine($"\n 优惠: {Discount.Description} 减免: {Discount.Amount:C}");
            }
            if(Invoice != null)
            {
                Console.WriteLine($"\n 发票信息: {Invoice.Type} 抬头: {Invoice.Title}");
            }
            decimal total = Payment.Amount;
            Console.WriteLine($"\n订单总计: {total:C}");
        }

    }
}
